<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://www.springframework.org/security/tags" prefix="security" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>修改报名信息</title>
<link href="images/css.css" type="text/css" rel="stylesheet" />
<script language="javascript">
	var req;
	
	function init() {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	//根据院系ID查询DropChangeAJAXAction，获得该院系的专业列表
	function changeDropOfClazz() {
		init();
		
		var url = "dropChangeAJAX.do?method=changeDropOfClazz&deptId=" + escape(document.forms[0].deptId.options[document.forms[0].deptId.selectedIndex].value);
		
		req.open("get", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	
	function callback() {
		if (4 == req.readyState) {
			if (200 == req.status) {
				eval(req.responseText);
			}
		}
	}
	
</script>
<script language="javascript">
	function checkForm() {
		var rankId = document.getElementById("rank_id").value;
		var IDCard = document.getElementById("idCard").value;
	
		if (rankId == 0) {
			alert("请选择报考等级及语言！");
			return false;
		}

		if (IDCard == null || IDCard == "") {
			alert("请输入身份证号码！");
			return false;
		} else {
			return isLegalIdCard(IDCard);
		}
		
		return true;
	}

	function isLegalIdCard(num) {  
	    num = num.toUpperCase();
	    //身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X。  
	    if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num))) {
	    	alert('输入的身份证号长度不对，或者号码不符合规定！\n15位号码应全为数字，18位号码末位可以为数字或X。');
	        return false;
	    }
		//校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
		//下面分别分析出生日期和校验位
		var len, re;
		len = num.length;
		if (len == 15) {
		re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
		var arrSplit = num.match(re);
	
		//检查生日日期是否正确
		var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]);
		var bGoodDay;
		bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
		if (!bGoodDay)
		{
        	alert('输入的身份证号里出生日期不对！');  
            return false;
		}
		else
		{
		//将15位身份证转成18位
		//校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
		          var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
		           var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
		           var nTemp = 0, i;  
		            num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6);
		           for(i = 0; i < 17; i ++)
		          {
		                nTemp += num.substr(i, 1) * arrInt[i];
		           }
		           num += arrCh[nTemp % 11];  
		            return num;  
		}  
		}
		if (len == 18)
		{
		re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
		var arrSplit = num.match(re);
	
		//检查生日日期是否正确
		var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]);
		var bGoodDay;
		bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
		if (!bGoodDay)
		{
		alert(dtmBirth.getYear());
		alert(arrSplit[2]);
		alert('输入的身份证号里出生日期不对！');
		return false;
		}
		else
		{
		//检验18位身份证的校验码是否正确。
		//校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。
		var valnum;
		var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
		var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
		var nTemp = 0, i;
		for(i = 0; i < 17; i ++)
		{
		nTemp += num.substr(i, 1) * arrInt[i];
		}
		valnum = arrCh[nTemp % 11];
		if (valnum != num.substr(17, 1))
		{
		alert('18位身份证的校验码不正确！应该为：' + valnum);
		return false;
		}
		return num;
		}
		}
		return false;
	}   
</script>
</head>

<body bgcolor="#FFFFFF">
<html:form action="enroll.do?method=updateEnroll" method="post" enctype="multipart/form-data" onsubmit="return checkForm();">
<html:hidden property="id" value="${enroll.id }" />
<div align="center"><span class="red14">带有<font
	color="#ff0000">*&nbsp;</font>号内的选项为必填项,网上报名数据必须真实准确，否则产生的一切后果由考生本人负责!
</span>
<table class="tableline" id="Table3" cellspacing="1" cellpadding="0" width="90%" border="0">
	<tr>
		<td style="WIDTH: 158px" align="right" width="158" bgcolor="#ffffff"
			height="25"><font face="宋体" color="#ff0000">*</font>&nbsp;报考等级及语言：</td>
		<td align="left" bgcolor="#ffffff"><label for="select"></label>
		&nbsp; 
			<html:select property="rank_id" value="${enroll.rank.id}" style="width:160px">
				<html:option value="0">请选择</html:option>
					<c:if test="${!empty rankList}">
						<c:forEach items="${rankList}" var="rank">
							<html:option value="${rank.id}">${rank.name}</html:option>
						</c:forEach>
					</c:if>
			</html:select>
			<c:if test="${!empty rank_idEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${rank_idEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			face="宋体" color="#ff0000">* </font><font face="宋体">身份证号：</font></td>
		<td style="WIDTH: 443px; HEIGHT: 32px" align="left" width="660"
			bgcolor="#ffffff">&nbsp;&nbsp;<html:text property="idCard" styleClass="date" style="width:155px"/>
			<font class="text12" face="宋体">&nbsp;请输入18位的身份证号码</font>
			<c:if test="${!empty idCardEmptyError || !empty IDCardError || !empty IDCardExist}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${idCardEmptyError }${IDCardError }${IDCardExist }</font>			
			</c:if>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			class="left" style="TEXT-ALIGN: right" face="宋体"><font
			face="宋体" color="#ff0000">*</font>&nbsp;姓 名：</font></td>
		<td align="left" bgcolor="#ffffff"><label for="textfield">&nbsp;
		</label> <html:text property="name" style="width:155px" />
			<c:if test="${!empty nameEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${nameEmptyError }</font>			
			</c:if></td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			color="#ff0000">*</font> 性 别：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; 
		<html:select property="sex" style="width:160px">
			<html:option value="0">请选择</html:option>
			<html:option value="1">男</html:option>
			<html:option value="2">女</html:option>
		</html:select>
		<c:if test="${!empty sexEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${sexEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			color="#ff0000">*</font> 出生年月日：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; 
			<html:text property="birthday"  style="width:155px"/>
			<font class="text12" face="宋体">&nbsp;请输入8位出生日期，例如19880608</font>
			<c:if test="${!empty BirthdayEmptyError || !empty BirthdayInputError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${BirthdayEmptyError }${BirthdayInputError }</font>			
			</c:if>	</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			face="宋体" color="#ff0000">* </font>民 族：</td>
		<td align="left" bgcolor="#ffffff"><label for="textfield3"></label>&nbsp; 
		<html:select property="nation" style="width:160px">
			<html:option value="0">请选择</html:option>
			<html:option value="01">汉</html:option>
			<html:option value="02">蒙古</html:option>
			<html:option value="03">回</html:option>
			<html:option value="04">藏</html:option>
			<html:option value="05">维吾尔</html:option>
			<html:option value="06">苗</html:option>
			<html:option value="07">彝</html:option>
			<html:option value="08">壮</html:option>
			<html:option value="09">布依</html:option>
			<html:option value="10">朝鲜</html:option>
			<html:option value="11">满</html:option>
			<html:option value="12">侗</html:option>
			<html:option value="13">瑶</html:option>
			<html:option value="14">白</html:option>
			<html:option value="15">土家</html:option>
			<html:option value="16">哈尼</html:option>
			<html:option value="17">哈萨克</html:option>
			<html:option value="18">傣</html:option>
			<html:option value="19">黎</html:option>
			<html:option value="20">傈僳</html:option>
            <html:option value="97">其他</html:option>
           
		</html:select>
		<c:if test="${!empty nationEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${nationEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25">&nbsp;&nbsp;<font
			face="宋体" color="#ff0000">*&nbsp;</font>职 业：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; <label for="textfield4"></label>
		<html:select property="profession" style="width:160px">
			<html:option value="0">请选择</html:option>
			<html:option value="30">学生</html:option>
			<html:option value="02">机关</html:option>
			<html:option value="04">事业</html:option>
			<html:option value="05">企业</html:option>
			<html:option value="08">军人</html:option>
			<html:option value="19">卫生</html:option>
			<html:option value="21">经济</html:option>
			<html:option value="22">金融</html:option>
			<html:option value="24">教育</html:option>
            <html:option value="99">其他</html:option>
          
		</html:select>
		<c:if test="${!empty professionEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${professionEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			face="宋体" color="#ff0000">* </font>文化程度：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; 
		<html:select property="degree" style="width:160px">
			<html:option value="0">请选择</html:option>
			<html:option value="1">博士</html:option>
			<html:option value="2">硕士</html:option>
			<html:option value="3">本科</html:option>
			<html:option value="4">大专(专科)</html:option>
			<html:option value="5">高中(职高)</html:option>
			<html:option value="6">中专(中技)</html:option>	
			<html:option value="7">初中</html:option>
			<html:option value="8">初中以下</html:option>						
		</html:select>
		<c:if test="${!empty degreeEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${degreeEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			face="宋体" color="#ff0000">* </font>联系电话：</td>
		<td align="left" bgcolor="#ffffff">&nbsp;
		<html:text property="phone"  style="width:155px"/> 
			<font class="text12" face="宋体">方便考点联系,请填写手机号码</font>
			<c:if test="${!empty PhoneEmptyError || !empty PhoneInputError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${PhoneEmptyError }${PhoneInputError }</font>			
			</c:if>	
			</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25"><font
			face="宋体" color="#ff0000">* </font>所在院系：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; <label for="textfield8"></label>
		<label for="select3"></label> 
			<html:select property="deptId" onchange="changeDropOfClazz()" value="${enroll.dept.id }" style="width:160px">
				<html:option value="0">请选择</html:option>
					<c:if test="${!empty deptList}">
						<c:forEach items="${deptList}" var="dept">
							<html:option value="${dept.id}">${dept.deptName}</html:option>
						</c:forEach>
					</c:if>
			</html:select>
		<font class="text12" face="宋体">请选择所在院系</font>
		<c:if test="${!empty dept_idEmptyError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${dept_idEmptyError }</font>			
			</c:if>
		</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25">所在班级：</td>
		<td align="left" bgcolor="#ffffff">&nbsp; 
			<html:select property="clazzId" value="${enroll.clazz.id}" style="width:160px">
		      <html:option value="0">请选择</html:option>
		      <c:if test="${!empty clazzList}">
		        <html:optionsCollection name="clazzList" label="clazzId" value="id"/>
		      </c:if>
		    </html:select>
			&nbsp;<font face="Arial" color="#999999">请选择所在班级</font>
			<c:if test="${!empty clazzEmptyError || !empty clazzInputError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${clazzEmptyError }${clazzInputError }</font>			
			</c:if>			
			</td>
	</tr>
	<tr>
		<td style="WIDTH: 158px" align="right" bgcolor="#ffffff" height="25">上传照片：
		</td>
		<td align="left" bgcolor="#ffffff">&nbsp; 
			<html:file property="file" /> &nbsp;
			<c:if test="${!empty imageEmptyError || !empty imgFormatError}">
				<img src="images/error.png" width="15" height="15" />&nbsp;<font color="red">${imageEmptyError} ${imgFormatError }</font>			
			</c:if>	
			<br/>
			<c:if test="${empty imageEmptyError || empty imgFormatError}">
				<font face="Arial" color="#999999">&nbsp;注意：照片必须是蓝底，且尺寸最好是150×210 像素，格式必须为jpg</font>
			</c:if>			
		</td>
	</tr>	
</table>
	<p>
		<html:submit value="修改报名信息" />&nbsp;&nbsp;&nbsp;&nbsp;
		<html:reset value="重填报名信息" />
	</p>
</div>
</html:form>
</body>
</html>